import { Prefab, resources } from "cc";
import { $planet_Elsb_poof$ } from "./ELSB";
import { $planet_Fruit_poof$ } from "./fruit";
import { $planet_Gift_poof$ } from "./gift";
import { $planet_Setting_poof$ } from "./setting";

export enum $planet_EPop_poof$ {
	$planet_ELSB_poof$,
	$planet_FRUIT_poof$,
	$planet_GIFT_poof$,
	$planet_SETTING_poof$,
}

const $planet_config_poof$ = {
	[$planet_EPop_poof$.$planet_ELSB_poof$]: {
		component: $planet_Elsb_poof$,
		// path: 'prefab/pop/ELSB',
		path: 'cHJlZmFiJTJGcG9wJTJGRUxTQg=='.$planet_decodeAtoB_poof$,
		// script: './ELSB',
		script: 'LiUyRkVMU0I='.$planet_decodeAtoB_poof$,
		prefab: null
	},
	[$planet_EPop_poof$.$planet_FRUIT_poof$]: {
		component: $planet_Fruit_poof$,
		// path: 'prefab/pop/fruit',
		path: 'cHJlZmFiJTJGcG9wJTJGZnJ1aXQ='.$planet_decodeAtoB_poof$,
		// script: './fruit',
		script: 'LiUyRmZydWl0'.$planet_decodeAtoB_poof$,
		prefab: null
	},
	[$planet_EPop_poof$.$planet_GIFT_poof$]: {
		component: $planet_Gift_poof$,
		// path: 'prefab/pop/gift',
		path: 'cHJlZmFiJTJGcG9wJTJGZ2lmdA=='.$planet_decodeAtoB_poof$,
		// script: './gift',
		script: 'LiUyRmdpZnQ='.$planet_decodeAtoB_poof$,
		prefab: null
	},
	[$planet_EPop_poof$.$planet_SETTING_poof$]: {
		component: $planet_Setting_poof$,
		// path: 'prefab/pop/setting',
		path: 'cHJlZmFiJTJGcG9wJTJGc2V0dGluZw=='.$planet_decodeAtoB_poof$,
		// script: './setting',
		script: 'LiUyRnNldHRpbmc='.$planet_decodeAtoB_poof$,
		prefab: null
	},
}

export async function $planet_GetPopPrefab_poof$(p: $planet_EPop_poof$): Promise<Prefab> {
	let conf = $planet_config_poof$[p];
	if(!conf.prefab){
		conf.prefab = await abd.$planet_cc_poof$.$planet_loadResAsync_poof$(conf.path, Prefab, resources);
	}

	return conf.prefab;
}

export async function $planet_GetPopComponent_poof$<P extends $planet_EPop_poof$>(p: P): Promise<(typeof $planet_config_poof$)[P]['component']> {
	let conf = $planet_config_poof$[p];
	if(!conf.component){
		conf.component = await import(conf.script).then(m=>m.default);
	}

	return conf.component;
}

export type $planet_PopCtor_poof$<P extends $planet_EPop_poof$> = typeof $planet_config_poof$[P]['component'];

export type $planet_PopIns_poof$<P extends $planet_EPop_poof$> = InstanceType<$planet_PopCtor_poof$<P>>;

export type $planet_PopParams_poof$<P extends $planet_EPop_poof$> = Parameters<$planet_PopIns_poof$<P>['$planet_onShow_poof$']>;

export type $planet_PopReturn_poof$<P extends $planet_EPop_poof$> = Awaited<ReturnType<$planet_PopIns_poof$<P>['$planet_show_poof$']>>;